home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Commodore Free 24
/
Commodore_Free_Issue_24_2008_Commodore_Computer_Club.d64
/
t.b guide 9.2
< prev
next >
Wrap
Text File
|
2023-02-26
|
11KB
|
369 lines
u
In the Beginning Chaper 9, Section 2
Lord Ronin from Q-Link
Tip for you here, you will see that
after 127. Things start showing up in
reverse video. If you know the code
for a symbol, just add 128 to that
code number and it will be in reverse
video.
Two areas are used in the computer
memory. For creating the symbol and
the colour on the screen. Meaning that
a block of memory from 1024 to 2023 is
for the screen. Colour is from 55296
to 56295. Yuppers another block of
memory for the colour that appears on
the screen.
In the above poke stuff to place the
ball on the screen and to change the
balls colour. Two poke codes where
used. One to place the ball and the
other to place the colour for the ball
in the right place.
Saying that in a couple of ways. You
can guess that there is probably
another 1000 square grid map. Right,
there is and the top left part starts
at 55296, and at the bottom right ends
at 56295. Before I go farther, it
should be stated that these areas, the
blocks of numbers can be called memory
locations. There are books that have
what is called the memory maps in
them, where you can see more about the
locations, including some ideas of
what is in there and what can be done
with those areas. This is something
that I am not skilled in, or
understand. I know that it is
important in Basic and it is important
in the Machine Language <ML> form of
programming. We aren't going there in
this series. Just wanted to give you a
heads up on this, as you may be
interested in going farther in
programming than Basic and this little
personal look at the users manual.
Feel free to make a grid for the
Colour Memory Map. Same as what we
talked about for the Screen one.
Numbers on the left hand side of the
map. Going down the rows, starts at
row 0 and ending at row 24. Goes like
this, start is 55296 for row 0 column
0. Row 24 column 0 is 56256. Row 0
column 39 is 55335. Spending some time
with these coordinates. You can make
the grid map. Naturally there is the
lazy way to figure out where you want
to put the colour on the screen. Yeah
I am still lazy. <VBG>
COLOUR POINT = 55296 + X +40*Y
Sure looks familiar doesn't it? <G>
the only change is that of the
starting point number. Matching the
top left corner of the colour memory
map grid. So yeah if you retro fit
that above poke thing to put the
colour into column 20 and row 12 it
would look like...
COLOUR POINT = 55296 + 20 + 40*12
COLOUR POINT = 55296 + 20 + 480
COLOUR POINT = 55796
Poke that in and add the colour of
0-15 spectrum and you have coloured
the character you put at that memory
location. Might seem that this is a
bit of work. At this point it is for
us. Gets better with time and other
things. OK I doubt that with some
tools you can use for making
programmes. Well you may not be doing
this form of math out all the time if
at all. Just see how much hands on
control of things you have with your
ideas for your programmes!
So then let us clear the screen and
prepare for typing in another
programme. I'm modifying this one for
us. Just a little colour change from
what the book says. Personal taste
here and you should feel free to alter
the colours to it what looks the best
to you. We will be putting in a symbol
here as well, for screen display,
again feel free to alter that to
something else.
new
10 ?"<shift clear/home>"
20 pO53280,0:pO53281,0
30 x=1:y=1
40 dx=1:dy=1
50 pO1024+x+40*y,81
60 fort=1to10:next
70 pO1024+x+40*y,32
80 x=x+dx
90 ifx<=0orx>=39thendx=-dx
100 y=y+dy
110 ify<=0ory>=24thendy=-dy
120 goto50
Done most of this already in
different forms, still let us go over
the lines. If you haven't run this
programme yet, this is another
bouncing ball programme. This one
though is different; this version
bounces the ball all over the screen,
being redirected as the ball hits the
border. Sort of like a pool ball.
Which causes me to remember that there
are pool games and pinball games for
the C=. This little thing you typed in
is a far cry from that level of
programming. Still though it is the
same sort of principal and shows you
some animation.
Line 10 is easy to understand. In
fact the book wants you to type it in
that way. I didn't alter that line
from the chr$(147). They didn't use
that command in this one.
Line 20 is also easy to understand
after what we have done. Changes the
screen and border colour. OK I did the
short hand code for the poke command.
Also I changed the colours to make the
screen and the border black. Book
colours are 7 for the border and 13
for the screen. Light green screen and
a yellow border.
Line 30 is a variable set up. Set
here to keep track of the row and
column position of the ball.
Line 40. DX & DY are variables; they
are also the horizontal and vertical
directions of the balls movements. Hey
don't worry if that doesn't sink into
your mind at this time, it doesnt for
me either. Exactly how that works,
point for point is magic to me.
Line 50 is recently familiar. Note
that it is the poke code and formula
to put the ball character onto the
screen. A few things to see here. See
that ,81 part at the far end of the
line. Remembering that previous thing
about putting the ball on the screen?
That was the ,81 remember? Note though
that the formula is the same frelling
thing as this programme line, meaning
that you don't have to figure out the
numbers for the screen placement, this
line does that for you. Using the
existing variables for X and Y. But
see that the 1024 is at the start as
its in the formula. Well when you run
this programme. You will see that the
ball starts out at the top left of the
screen. Goes to the bottom right and
bounces around the screen.
At line 60 there is the for next
loop, producing a short time delay.
Here is something to notice. Remember
that 2000 we had in the screen and
border change? Here it is a delay of
10. Obviously a much shorter delay.
Here is a lesson not discussed in the
book. Setting the delay for your
programme. Can't really help you on
this part. I can Only say that you may
need to adjust the time delay to fit
yourself and other people. If you find
this 1 to10 one a bit too flickery of
the image of the ball. Try adding to
the number or shortening it to a
smaller value.
Looking at Line 70 we see the same
smegging screen point formula. Again
it is doing all the work for you in
the placement of the ball on the
screen. Except you see that ,32 at the
end. Above I stated in the part where
you where playing with the numbers for
different symbols. Said there that
this 32 was one of the two numbers for
the space. So then what is happening
here is that the formula isn't putting
the ball on the screen. In fact it is
doing the opposite. Erasing the ball
from the screen. REM this line and see
what the programme does <VBG>.
Next is Line 80 and this line is
adding a direction factor to the X
<vertical>. Taking us to line 90. You
can see that this is an IF THEN
statement. By a simple look the
numbers are 0 and 39 in this line. Hmm
that happens to be the designation
numbers of the 40 columns or the X
factor in this programme. As you see
if X is less than or equal to 0, the
left hand side of the screen. Or it is
greater than or equal to 39, the right
hand side of the screen. That value of
DX suddenly becomes negative with the
value of -DX. Or better said, that
makes the ball bounce off of the sides
of the screen.
Next line is line100 and that looks a
bit like line 80. Hey line 110 looks a
bit like line 90. Save for the fact
that this is the Y part. Or the top
and bottom of the screen. Making the
ball bounce. You can bugger this up a
bit by altering the DX and the DY.
Tell you that one member made a
mistype and that made the ball just go
back and forth on the 0 row.
Well that looks real nice, and it is
an amazing thing to do when you type
it in the first time. Remember that
you did this yourself. This is your
creation. Alter it a bit with a symbol
of your choice. Personally I used the
"\" symbol for the ball.
Not finished with this one yet. Here
are some lines to add to the
programme.
21 forL=1to10
25 pO1024+int(rnd(1)*1000),166
27 nextL
85 ifpeek(1024+x+40*y)=166thendx=-dx
100ifpeek(1024+x+40*y)=166thendy=-dy
This does a what? Some of it looks
familiar; some of it looks real
familiar.
First new is a stock for part of a for
next loop. Here I intentionally used
the upper case L as one of the
problems in typing things in from a
book is the confusion of a 1 and a l.
Ok and 0 vs. O as well. Type face or
more commonly they are called fonts.
Are confusing in the books. As it just
don't look like what is on the screen
in the C= font.
Saying that we see that there is only
10 things. We see also that the NEXT
part of this loop is in line 27. So
then what ever happens in that line 25
is done 10 times. As we know it is
going to loop between these lines till
all 10 things are done.
Line 25 sort of looks like the thing
that puts the symbol on the screen. At
least it starts out that way. But we
are then tossed into a different form
of a random number generator and there
are 1000 things? This is what is
happening on this line. Each time it
is run, and that is 10 times from the
for-next loop. One location out of the
1000 possible locations is going to be
generated and is going to be added to
the base number of 1024. Meaning that
this is a line to create something on
the screen at purely random locations.
At the end of the line is that ,166
code. That is the symbol. Ok this
means that the programme will go 10
times through this for next loop.
Generating a screen location and
putting in that location the symbol
for 166. IIRC that is the reverse
video & symbol. I change it each time
I play with the programme. Looks
better if it is the reverse video.
Remember about adding 128 to the code
number to get the reverse video of the
character.
On the screen will be these 10
symbols. OK so that is nice and what
will that mean? Take a look at line 85
and then at line 105. Look a bit
familiar from a couple of lines in
this programme already? Right, the
difference is the 166 code number. If
this line works like the ones for the
four sides of the screen, then this
must look for that code numbered
symbol on the screen as well, and it
will do the same thing. As you see by
the fact the variable becomes a
negative number. Run it and you have
10 obstacles on the screen, that will
make the ball bounce off of the sides
of the screen and off of these
symbols. Play around with the symbols
and the number of obstacles to see
what you can create. Don't worry about
the colour at this time. If you think
you can figure out how to make the
colour of the ball different from the
obstacles then feel free to give it a
shot. Not really needed at this time.
Good experimentation though.
Next we move into sprites and a lot
of difficulty in trying to paint a
word picture of what is going on.
The reason for that statement is
simply that there are some graph
charts in the book. These charts are
drawn in a way that I am not at the
least bit certain I can recreate them
in my word writing programme. I'll
give it my best shot. Hopefully I can
illustrate with words, what I can't
illustrate with the graphics.
Good news for you is that there isn't
enough space in this instalment to go
into the details of sprites. We will
pick it up in the next session.
====